home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / aever / aever.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  10.0 KB  |  377 lines

  1. #include <exec/exec.h>
  2. #include <dos/datetime.h>
  3. #include <dos.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <clib/dos_protos.h>
  7. #include <clib/exec_protos.h>
  8. #include <string.h>
  9. #include "work:romconf/doorheader.h"
  10. #include "source:aztec/glue.h"
  11. int mynode;
  12. char string[200];
  13. char temp[200];
  14. void end(void);
  15. void LastCommand(void);
  16. #define sm sendmessage
  17. #define hk hotkey
  18. #define pm prompt
  19. #define pu putuserstring
  20. #define gu getuserstring
  21. void sr(char *s);
  22. void GetFileDate(char *s);
  23. char Path[200];
  24.  char Dat[20];
  25.   char DatTime[20];
  26.  char DatSize[20];
  27.  char Temp1[20];
  28. char tempname[200];
  29. char Name[200];
  30. char t[200];
  31. char p[200];
  32. char RegNum[40];
  33. char tempname1[200];
  34. char OutPutName[200];
  35. int FindIt(char *str,char *FileName);
  36. void Prepare();
  37. #define TX(x) (UBYTE)Number.Text[x]
  38. int PurgeIt(char *str,char *FileName,char *NewName);
  39. void Serialize(void);
  40. long lock=NULL;
  41. struct REGIT
  42. {
  43.    char Text[8];
  44.    long chksum;
  45. };
  46. struct REGIT Number;
  47. main(int argc,char *argv[])
  48.   int i;
  49.   FILE *fi,*st;
  50.   if(argc!=2)
  51.   {
  52.     printf("AutoRegister version 2.2, written by Joseph Hodge\n");
  53.     printf("\n\n");
  54.     exit(0);
  55.   }
  56.   Register(argv[1][0]-'0');
  57.   mynode=argv[1][0]-'0';
  58.   strcpy(Path,argv[0]);
  59.   i=strlen(Path)-1;
  60.   while(Path[i]!='/' && Path[i]!=':') i--;
  61.   Path[i+1]='\0';
  62.     sm("",1);
  63.     sm("AutoRegister 2.2, written by Joseph Hodge",1);
  64.     sm("",1);
  65.     sprintf(tempname,"%sLockme",Path);
  66.   if(!(lock=Lock(tempname,ACCESS_WRITE)))
  67.   {
  68.     sm("",1);
  69.     sm("Sorry but an Update is currently being give on another node",1);
  70.     sm("Please try again in a few minutes",1);
  71.     ShutDown();
  72.     end();
  73.   }
  74.    
  75.   gu(Name,DT_NAME);strupr(Name);
  76.     strcpy(t,"VALIDATE");
  77.     pu(t,RETURNCOMMAND);
  78.     Chain("DOORS:FORMEDIT/FORMEDIT",argv[1][0]-'0',WAIT);
  79.     strcpy(t,"");
  80.     pu(t,RETURNCOMMAND);
  81.     sprintf(tempname,"Registered:Validate/Validate.db",Path);
  82.     if(!FindIt(Name,tempname))
  83.     {
  84.       sm("You must complete the validation FORM.",1);
  85.       sm("Aborting registration.",1);
  86.       ShutDown();
  87.       end();
  88.     }
  89.  
  90.     
  91.   sm("Version stats",1);
  92.   sm("-------------",1);
  93.    sprintf(string,"version >ram:%dver.txt %sexpress FULL\n",mynode,Path);
  94.   Execute(string,NULL,NULL);
  95.   sprintf(string,"%sexpress",Path);
  96.   if(!access(string,00))
  97.   sprintf(string,"ram:%dver",mynode); else strcpy(string,"");
  98.   sm(" 1>/X Express : ",0); showgfile(string);
  99.   sprintf(string,"%sexpress",Path); GetFileDate(string); 
  100.   sprintf(string,"%s %s %s",Dat,DatTime,DatSize);
  101.   if(string[0]!=' ')sm("              :   ",0); sm(string,1);
  102.   sm("",1);
  103.  
  104.   sprintf(string,"version >ram:%dver.txt %sacp FULL\n",mynode,Path);
  105.   Execute(string,NULL,NULL);
  106.   sprintf(string,"%sacp",Path);
  107.   if(!access(string,00))
  108.   sprintf(string,"ram:%dver",mynode); else strcpy(string,"");
  109.  
  110.   sm(" 2>/X ACP     : ",0); showgfile(string);
  111.   sprintf(string,"%sACP",Path); GetFileDate(string); 
  112.   sprintf(string,"%s %s %s",Dat,DatTime,DatSize);
  113.   if(string[0]!=' ')sm("              :   ",0); sm(string,1);
  114.   sm("",1);
  115.  
  116.   sprintf(string,"%sBBS.DOX",Path); GetFileDate(string); 
  117.   sprintf(string,"%s %s %s",Dat,DatTime,DatSize);
  118.   sm(" 3>/X DOX     :   ",0); sm(string,1);
  119.  
  120.   sprintf(string,"%sBBS.LZH",Path); GetFileDate(string);
  121.   sprintf(string,"%s %s %s",Dat,DatTime,DatSize);
  122.   sm(" 4>/X Package :   ",0); sm(string,1);
  123.   sm("-------------",1);
  124.   
  125.   while(1)
  126.   {
  127.     sm("",1);
  128.     sm("Select Item to download or 'Q' to Quit >:",0);
  129.     hk("",string);
  130.     switch(string[0])
  131.     {
  132.  
  133.       case '1':
  134.         sm("1.",1);
  135.      
  136.         sprintf(string,"%sexpressx000",Path);
  137.         if(!access(string,00))
  138.         {
  139.         Serialize();
  140.         hk("press anykey to begin download",temp);sm("",1);
  141.         Download(string);
  142.         }else sm("Sorry, this file is not available at this time",1);
  143.         break;
  144.         
  145.       case '2':
  146.       sm("2.",1);
  147.       
  148.        sprintf(string,"%sacp.ctrl",Path);
  149.         if(!access(string,00))
  150.         {
  151.         hk("press anykey to begin download",temp);sm("",1);
  152.         Download(string);
  153.         }else sm("Sorry, this file is not available at this time",1);
  154.         break;
  155.       case '3':
  156.        sm("3.",1);
  157.      
  158.         sprintf(string,"%sBBS.DOX",Path);
  159.         if(!access(string,00))
  160.         {
  161.         hk("press anykey to begin download",temp);sm("",1);
  162.               Download(string);
  163.  }else sm("Sorry, this file is not available at this time",1);
  164.  
  165.         break;
  166.       case '4':
  167.        sm("4.",1);
  168.         sprintf(string,"%sBBS.LZH",Path);
  169.         if(!access(string,00))
  170.         {
  171.         hk("press anykey to begin download",temp);sm("",1);
  172.         Download(string);
  173.  }else sm("Sorry, this file is not available at this time",1);
  174.  
  175.         break;
  176.  
  177.       case 'Q':
  178.       case 'q':
  179.   sm("",1);
  180.   sm("",1);
  181.   //sm(" IMPORTANT FACTS: Any version of express that you may download",1);
  182.   //sm(" via this door is strictly BETA, don't spread this, it may do more",1);
  183.   //sm(" harm than good",1);
  184.   //sm("",1);
  185.   //sm("",1);
  186.  
  187.         ShutDown(); end();
  188.     }
  189.  
  190.   }
  191.  
  192.  
  193. }
  194. void end(void)
  195. {
  196.   exit(0);
  197. }
  198. void LastCommand(void)
  199. {
  200.   char temp[200];
  201.  sprintf(temp,"ram:%dver",mynode); 
  202.   DeleteFile(temp);
  203.   sprintf(temp,"%sInfo",Path);
  204.   showgfile(temp);
  205.   if(lock) UnLock(lock);
  206.   
  207. }
  208. void GetFileDate(char *s)
  209. {
  210.   struct FileInfoBlock *FBlock;
  211.   struct DateTime d;
  212. BPTR FLock;
  213.   strcpy(Dat,"");
  214.   strcpy(DatTime,"");
  215.   strcpy(DatSize,"");
  216.    
  217.   if((FLock=Lock(s,ACCESS_READ)))
  218.   {
  219.     FBlock=AllocMem((long)sizeof(struct FileInfoBlock),MEMF_CHIP);
  220.     Examine(FLock,FBlock);
  221.     UnLock(FLock);
  222.     sprintf(DatSize,"%ld",FBlock->fib_Size);
  223.     d.dat_Stamp=FBlock->fib_Date;
  224.     d.dat_StrDate=&Dat;
  225.     d.dat_StrTime=&DatTime;
  226.     d.dat_Format=FORMAT_USA;
  227.     d.dat_StrDay=0;
  228.     d.dat_Flags=0;
  229.     DateToStr(&d);
  230.     FreeMem(FBlock,sizeof(struct FileInfoBlock));
  231.   }
  232. }  
  233. int FindIt(char *str,char *FileName)
  234. {
  235.   FILE *fi;
  236.   char image[200];
  237.   if(!TLock(FileName)) return(0);
  238.   strupr(str);
  239.   fi=fopen(FileName,"r");
  240.   while(fgets(image,80,fi)!=NULL)
  241.   {
  242.      sr(image);
  243.      strupr(image);
  244.      if(!strcmp(image,str))
  245.      {
  246.        fclose(fi);
  247.        return(1);
  248.      }
  249.    }
  250.    fclose(fi);
  251.    return(0);
  252. }
  253. int PurgeIt(char *str,char *FileName,char *NewName)
  254. {
  255.   FILE *fi,*fo1,*fo2;
  256.   char image[200];
  257.   int returncode=0;
  258.   if(!TLock(FileName)) return(0);
  259.   sprintf(image,"%s.tmp",FileName);
  260.   if(!TLock(image))
  261.   {
  262.      Rename(FileName,image);
  263.   }
  264.   strupr(str);
  265.   fi=fopen(image,"r");
  266.   fo1=fopen(FileName,"w");
  267.   fo2=fopen(NewName,"a");
  268.   while(fgets(image,80,fi)!=NULL)
  269.   {
  270.      sr(image);
  271.      strupr(image);
  272.      if(!strcmp(image,str))
  273.      {
  274.        fprintf(fo2,"%s\n",image);
  275.        returncode=1;
  276.        
  277.      }
  278.      else fprintf(fo1,"%s\n",image);
  279.    }
  280.    fclose(fi);
  281.    fclose(fo1);
  282.    fclose(fo2);
  283.   sprintf(image,"%s.tmp",FileName);
  284.  
  285.    DeleteFile(image);
  286.    return(returncode);
  287. }
  288. void sr(char *str)
  289. {
  290.   register int i;
  291.   i=strlen(str)-1;
  292.   while(i>-1)
  293.   {
  294.     if(*(str+i)<=32) *(str+i)='\0'; else break;
  295.     i--;
  296.   }
  297. }
  298. void Serialize(void)
  299. {
  300.   int i=0;
  301.   FILE *fi,*st;
  302.   static int j=0;
  303.   if(!j)
  304.   {
  305.   sprintf(tempname,"%sUpdate.Dat",Path);
  306.   if(!FindIt(Name,tempname))
  307.   {
  308.             Number.chksum=time(NULL);
  309.            sprintf(OutPutName,"%sUpdate.Dat",Path);
  310.            st=fopen(OutPutName,"a");
  311.            fprintf(st,"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
  312.            fprintf(st,"%s\n",Name);
  313.            fprintf(st,"CheckSum %ld ",Number.chksum);
  314.            fprintf(st,"SumKickDate %s",ctime(&Number.chksum));
  315.            fprintf(st,"REG:%s-%u%u%u%u%u%u%u%u%u-%u.%u%u\n",Name,TX(11),TX(1),TX(9),TX(3),TX(4),TX(8),TX(6),TX(7),TX(5),TX(2),TX(10),TX(0));
  316.            fclose(st); 
  317.            sm("",1);
  318.            sprintf(p,"%u%u%u%u%u%u%u%u%u-%u.%u%u",TX(11),TX(1),TX(9),TX(3),TX(4),TX(8),TX(6),TX(7),TX(5),TX(2),TX(10),TX(0));
  319.            sm("Your Registration number is >:",0);
  320.            sm(p,0);sm("",1);sm("",1);
  321.    sm("Please record your Registration number, It will be needed to get",1);
  322.    sm("product assistance and future updates.",1);
  323.    sm("",1);
  324.    hotkey("Press (enter) to continue",tempname);
  325.    sm("",1);
  326.   }
  327.   else
  328.   {
  329.       pm("Please Enter registration number >:",RegNum,30);
  330.          strcpy(p,RegNum);
  331.          sprintf(t,"REG:%s-%s",Name,RegNum); strupr(t);
  332.          sprintf(tempname,"%sUpdate.dat",Path);
  333.          sprintf(tempname1,"%sUpdate.old",Path);
  334.  
  335.           if(!FindIt(t,tempname))//,tempname1))
  336.            {
  337.              sm("",1);
  338.              sm("Records indicate that this is an invalid Registration.",1);
  339.              sm("Please leave a message with the sysop for further assistance.",1);
  340.              sm("",1);
  341.              ShutDown();
  342.              end();
  343.            }
  344.       /*
  345.        Number.chksum=time(NULL);
  346.            sprintf(OutPutName,"%sUpdate.dat",Path);
  347.            st=fopen(OutPutName,"a");
  348.            fprintf(st,"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
  349.            fprintf(st,"%s\n",Name);
  350.            fprintf(st,"CheckSum %ld ",Number.chksum);
  351.            fprintf(st,"SumKickDate %s",ctime(&Number.chksum));
  352.            fprintf(st,"REG:%s-%u%u%u%u%u%u%u%u%u-%u.%u%u\n",Name,TX(11),TX(1),TX(9),TX(3),TX(4),TX(8),TX(6),TX(7),TX(5),TX(2),TX(10),TX(0));
  353.            fclose(st); 
  354.            sm("",1);
  355.            sprintf(p,"%u%u%u%u%u%u%u%u%u-%u.%u%u",TX(11),TX(1),TX(9),TX(3),TX(4),TX(8),TX(6),TX(7),TX(5),TX(2),TX(10),TX(0));
  356.            sm("Your New Registration number is >:",0);
  357.            sm(p,0);sm("",1);sm("",1);
  358.  
  359.    sm("Please record your Registration number, It will be needed to get",1);
  360.    sm("product assistance and future updates.",1);
  361.    sm("",1);
  362.       */
  363.     hotkey("Press (enter) to continue",tempname);
  364.    sm("",1);
  365.   }
  366.   j=1;
  367.   }
  368.   sm("",1);
  369.   sm(" STANDBY serializing file",1);
  370.   for(i=0;i<strlen(p);i++)
  371.   {
  372.      sm(".",0); Delay(30L);
  373.   }
  374.   sm("",1);
  375.   sm("",1);
  376. }